package com.yuanxuzhen.ijkplayerdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import java.io.File;

import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        IjkMediaPlayer.loadLibrariesOnce(null);
        IjkMediaPlayer.native_profileBegin("libijkplayer.so");
        VideoPlayerIJK videoPlayerIJK = findViewById(R.id.video_view);
        videoPlayerIJK.setListener(new VideoPlayerListener() {
            @Override
            public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i) {
                Log.e("yuan", "onBufferingUpdate");
            }

            @Override
            public void onCompletion(IMediaPlayer iMediaPlayer) {
                Log.e("yuan", "onCompletion");

            }

            @Override
            public boolean onError(IMediaPlayer iMediaPlayer, int i, int i1) {
                Log.e("yuan", "onError");

                return false;
            }

            @Override
            public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i1) {
                Log.e("yuan", "onInfo");

                return false;
            }

            @Override
            public void onPrepared(IMediaPlayer iMediaPlayer) {
                Log.e("yuan", "onPrepared");


            }

            @Override
            public void onSeekComplete(IMediaPlayer iMediaPlayer) {
                Log.e("yuan", "onSeekComplete");


            }

            @Override
            public void onVideoSizeChanged(IMediaPlayer iMediaPlayer, int i, int i1, int i2, int i3) {
                Log.e("yuan", "onVideoSizeChanged");

            }
        });
        Log.e("yuan", "path="+DirUtil.getCacheDir(this) + File.separator +  "123.mp4");

        videoPlayerIJK.setVideoPath(DirUtil.getCacheDir(this) + File.separator + "123.mp4");
        videoPlayerIJK.start();
    }


}